package com.douya.common.pojo.entity;

import cn.hutool.core.lang.Snowflake;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * es 基础 entity
 *
 * @Author hcy
 * @Date 2022/11/29
 */
@Data
@ToString(callSuper = true)
@Accessors(chain = true)
public class ElasticSearchEntity {

    private static final Snowflake SNOWFLAKE = new Snowflake(1, 1);

    public static Long snowflakeId() {
        return SNOWFLAKE.nextId();
    }

    /**
     * ID 设置为雪花算法
     */
    @Id
    Long id = snowflakeId();

    /**
     * 创建时间
     */
    LocalDateTime createTime;

    /**
     * 更新时间
     */
    LocalDateTime updateTime;

}
